package com.wangfei.test.filehandler;

import java.util.regex.Pattern;

public enum Type {

    /**
     * project id
     */
    NUMERIC("UOS(\\d{6,7})", 0),
    /**
     * chinese date
     */
    DATE("([1-9]|1[0-2])月(0[1-9]|[12][0-9]|30|31)日", 1),
    /**
     * numeric date
     */
    DATENUMERIC("20\\d{2}(0[1-9]|1[0-2])(0[1-9]|[12][0-9]|30|31)", 2),
    /**
     * model模块
     */
    MOUDLE("查看模块.+是否", 3),
    /**
     * ip
     */
    IPADDRESS("([0-255].{3})[0-255](/[0-255]{1,3})", 4);



    private String value;
    private int index;

    private Type(String value, int index){
        this.value = value;
        this.index = index;
    }

    public static int getIndex(String value) {
        for(Type t : Type.values()){
            if(value.equals(t.getValue())) {
                return t.index;
            }
        }
        return -1;
    }

    public int getIndex(){
        return index;
    }

    public String getValue(){
        return value;
    }

    public static Pattern getPattern(String value){
        return Pattern.compile(value);
    }
}